#ifndef LIBCELL_QEM_H_
#define LIBCELL_QEM_H_
#include<Algorithm/threeD_elementary_geometry_tool_library.h>
#include<Mesh/Mesh.h>
#include<tools_heap.h>

#ifdef __cplusplus
extern "C" {
#endif

typedef struct Edge_Energy{
    double energy;
    int fid;
    double* p;
    void* prop;
}Edge_Energy;

static inline void edge_energy_init(Edge_Energy* ee)
{
    ee->energy=0;
    ee->p=NULL;
    ee->fid=-1;
    ee->prop=NULL;
}
static inline void edge_energy_free(Edge_Energy*ee)
{
    if(ee==NULL)
    {
        return;
    }
    SAFE_FREE(ee->p);
    free(ee);
}
Int_RB_Tree* qem_init_qi(Mesh * m);



CHeap *compute_qem_all_edge_position_and_energy(Mesh* m,Int_RB_Tree*tree);

template_v* qem_collapse_edge(Mesh *m ,Edge_Energy*ee,Int_RB_Tree* tree_v,CHeap*ch);




#ifdef __cplusplus
}
#endif


#endif
